<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Youzi
 * Date: 12-11-11
 * Time: 下午8:35
 * To change this template use File | Settings | File Templates.
 */
class OaController extends Controller
{

    /**
     * 会议记录
     */
    public function RecordAction()
    {
        /*
         * 权限控制
         */
        $p["sid"] = $this->user["id"];
        $staff = OaModel::getInstance()->getStaffInfo($this->user["id"]);

        $this->JS['STAFF'] = json_encode($staff);

        /* 获取部门 */
        $dlist = OaModel::getInstance()->getDepartmentAll($staff);
        $allStaff = OaModel::getInstance()->getStaffAll($staff);

        $this->data['allstaff'] = $allStaff;
        $this->data['department'] = $dlist;
        $this->view('oa/record.list', "E");
    }

    public function RecordPatternAction()
    {
        $page = P("page", 1);
        $pageSize = P("rows", 10);
        $agency_id = G("aid", 0);
        $var = array();
        $list = MinutesModel::getInstance()->getList('id',$agency_id, $page, $pageSize);
        foreach ($list as $key=>$item) {
            $item['forecast_format'] = date("Y-m-d H:i:s", $item['forecast']);
            $item['forecast_date_format'] = current(explode(' ',$item['forecast_format']));
            $item['forecast_time_format'] = end(explode(' ',$item['forecast_format']));

            if ($item['start_time']) {
                $item['start_time_format'] = date("Y-m-d H:i:s", $item['start_time']);
                $item['start_time_format_date'] = current(explode(' ', $item['start_time_format']));
                $item['start_time_format_time'] = end(explode(' ', $item['start_time_format']));
            } else {
                $item['start_time_format'] = '还没开始会议';
                $item['start_time_format_date'] = '';
                $item['start_time_format_time'] = '';
            }

            if ($item['end_time']) {
                $item['end_time_format'] = date("Y-m-d H:i:s", $item['end_time']);
                $item['end_time_format_date'] = current(explode(' ', $item['end_time_format']));
                $item['end_time_format_time'] = end(explode(' ', $item['end_time_format']));
            } else {
               $item['end_time_format'] = '还没开始会议';
               $item['end_time_format_date'] = '';
               $item['end_time_format_time'] = '';
            }
            $var[$key] = $item;
        }
        $this->json->toJson(
            array(
                "total" => MinutesModel::getInstance()->getCount($agency_id),
                "rows"  => $var
            )
        );
    }

    public function RecordViewAction()
    {
        $id = (int) G("id");
        $info = MinutesModel::getInstance()->getInfo($id);
        $this->data['info'] = $info;
        $this->view("oa/record.view");
    }
    /**
     * 发起会议
     */
    public function RecordAddAction()
    {
        $staff = OaModel::getInstance()->getStaffInfo($this->user["id"]);

        $id = P("id", 0);
        $forecast = P('forecastDate')." ".P('forecastTime');
        $startTime = P('start_time')
            ? strtotime(P('start_time')." ".P("start_times"))
            : '';
        $endTime   = P('end_time')
            ? strtotime(P('end_time')." ".P("end_times"))
            : '';
        $data = array(
            'dis_agency_id' => $staff['manage_agency_id'] ? $staff['manage_agency_id'] : $staff['agency_id'],
            'title'       => P('title'),
            'host'        => P('host') ? P('host') : $this->user['user'],
            'participant' => P('participant_id'),
            'forecast'    => strtotime($forecast),
            'start_time'  => $startTime,
            'end_time'    => $endTime,
            'result'      => P('minute_result'),
            'content'     => P('content'),
            'remark'      => P('remark'),
        );
        if (P('title') && P('participant_id')) {

            if (!$id) {
                $data['created'] = time();
                $result = MinutesModel::getInstance()->add($data);
            } else {
                $result = MinutesModel::getInstance()->edit($data, $id);
            }
            if ($result) {
                // 判断数据库插入是否正常
                $this->json->code('OK')->out();
                return false;
            } else {
                echo 222;exit;
            }
        }
    }

    /**
     * 修改会议
     */
    public function RecordEditAction()
    {
        $id = (int) P('id');
        if ($id && P('title') && P('participant') && P('forecast')) {
            $data = array(
                'title'         => P('title'),
                'content'       => P('content'),
                'result'        => P('result'),
                'host'          => $this->user['user'],
                'participant'   => P('participant'),
                'forecast'      => strtotime(P('forecast')),
                'start_time'    => strtotime(P('start_time')),
                'end_time'      => strtotime(P('end_time')),
                'remark'        => P('remark'),
            );
            if (MinutesModel::getInstance()->edit($data, $id)) {
                // 判断数据库插入是否正常
                $this->json->code('OK')->out();
                return false;
            }
        }
    }


    /**
     * 删除会议记录
     */
    public function RecordDelAction()
    {
        $id = P('deleted');
        if (MinutesModel::getInstance()->del($id, false)) {
            // 判断数据库插入是否正常
            $this->json->code('OK')->out();
            return false;
        }
    }

    /**
     * 考勤特殊安排
     */
    public function AttendanceArrangeAction()
    {
        $var = array();
        $list = AttendanceArrangeModel::getInstance()->getList();
        foreach ($list as $key=>$item) {
            $item['date_format'] = $item['year'].'-'.$item['month'].'-'.$item['day'];
            $var[$key] = $item;
        }
        $this->data['listjson'] = json_encode($var);
        $this->data['list'] = $list;
        $this->view('oa/attendance.arrange.list');
    }

    /**
     * 添加考勤特殊安排
     */
    public function AttendanceArrangeAddAction()
    {
        if (P('date')) {
            list($year, $month, $day) = explode('-', P('date'));
            $data = array(
                'year'    => $year,
                'month'   => $month,
                'day'     => $day,
                'am'      => P('am'),
                'pm'      => P('pm'),
                'created' => time()
            );
            if (AttendanceArrangeModel::getInstance()->add($data)) {
                // 判断数据库插入是否正常
                $this->json->code('OK')->out();
                return false;
            }
        }
    }

    /**
     * 修改考勤特殊安排
     */
    public function AttendanceArrangeEditAction()
    {
        $id = (int) P('id');
        if (P('date') && $id) {
            list($year, $month, $day) = explode('-', P('date'));
            $data = array(
                'year'    => $year,
                'month'   => $month,
                'day'     => $day,
                'am'      => P('am'),
                'pm'      => P('pm'),
            );
            if (AttendanceArrangeModel::getInstance()->edit($data, $id)) {
                // 判断数据库插入是否正常
                $this->json->code('OK')->out();
                return false;
            }
        }
    }

    /**
     * 删除考勤特殊安排
     */
    public function AttendanceArrangeDelAction()
    {
        $id = (int) P('id');
        if (AttendanceArrangeModel::getInstance()->edit(array('stop'=>1), $id)) {
            // 判断数据库插入是否正常
            $this->json->code('OK')->out();
            return false;
        }
    }

    public function StaffAction()
    {
        $this->view('oa/staff.list', 'E');
    }

    public function StaffPatternAction()
    {
        $page = P("page", 1);
        $pageSize = P("rows", 10);

        $list = OaModel::getInstance()->getStaffList('id', $page, $pageSize);
        $this->json->toJson(
            array(
                "total"=>OaModel::getInstance()->getStaffCount(),
                "rows"=>$list
            )
        );
    }

    public function StaffAddAction()
    {
        $id = P("id", 0);
        $loginid = P('login_id') ? P('login_id') : P("old_login_id");

        $staffModel = StaffModel::getInstance();
        $uinfo = $staffModel->getUserRow("`user`='".$loginid."'");


        $tmpInfo = $staffModel->getByRow("login_id=".$uinfo['id']." and id!=$id");
        if ($tmpInfo['login_id']) {
            die(json_encode(array('err'=>'帐号登录被占用，请添加一个唯一的登录帐号')));
        }

        $pinfo = PositionModel::getInstance()->getByRow("name='".P('position_name')."'");
        $data = array(
            'login_id'      => $uinfo['id'],
            'agency_id'     => $uinfo['agency_id'],
            'department_id' => $uinfo['department_id'],
            'name'          => P('name'),
            'position_name' => $pinfo ? $pinfo['id'] : '0',
            'sex'           => P('sex'),
            'age'           => P('age'),
            'birthday'      => P('birthday'),
            'mobile_phone'  => P('mobile_phone'),
            'tel'           => P('tel'),
            'remark'        => P('remark'),
            'created'       => time()
        );
        if (!$id) {
            $id = $staffModel->add($data);
            $staffModel->edit(array('sn'=>'00'.$sid), $sid);
        } else {
            $data['created'] = time();
            $staffModel->edit($data, $id);
        }

        if ($id) {
            $this->json->code('OK')->out();
        } else {
            die(json_encode(array('err'=>'编辑员工失败')));
        }
    }

    public function StaffDelAction()
    {
        $id = trim(P("deleted"));
        if (StaffModel::getInstance()->del($id, false)) {
            $this->json->code('OK')->out();
        }
    }
    public function UserPatternAction()
    {
        $page = P("page", 1);
        $pageSize = P("rows", 7);
        $list = StaffModel::getInstance()->getUserList($page, $pageSize);
        $count = StaffModel::getInstance()->getUserCount();
        $this->json->toJson(array('total'=>$count['n'],'rows'=>$list));
    }

    /**
     * 员工考勤
     */
    public function AttendanceAction()
    {
        $condition = '';
        if ($this->user["id"] > 1) {
            $staff = OaModel::getInstance()->getStaffInfo($this->user["id"]);
            $condition = ' and a.staff_id='.$staff['staff_id'];
        }
        //AttendanceModel::getInstance()->getRows($condition);
        $this->view("oa/attendance.list", "E");
    }

    function AgencyListAllAction(){
        $agency_list = array();
        $agency = OaModel::getInstance()->AgencyListAll();
        $tt = ArrayTool::ArrayToNode($agency);
        echo json_encode($tt);
    }

    /**
     * 员工考勤--数据
     */
    public function AttendancePatternAction()
    {
        $agency     = (int) P("agency");
        $staff      = (int) P("staff");
        $start_time = P("start_time");
        $end_time   = P("end_time");

        $page     = P("page", 1);
        $pageSize = P("rows", 10);

        $timewhere = $condition = '';
        $condition = '';
        if ($this->user["id"] > 1) {
            $staffs = OaModel::getInstance()->getStaffInfo($this->user["id"]);
            $timewhere .= ' and a.staff_id='.$staffs['staff_id'];
        }

        if ($start_time) {
            $timewhere .= " and UNIX_TIMESTAMP(a.attendance_date)>=".strtotime($start_time);
        }

        if ($end_time) {
            $timewhere .= " and UNIX_TIMESTAMP(a.attendance_date)<=".strtotime($end_time);
        }

        if ($this->user["id"] == 1 && $staff) {
            $condition .= " and a.staff_id=$staff ";
        } else {
            if ($agency) {
                $condition .= " and b.agency_id=$agency";
            }
        }
        $condition .= $timewhere;

        $row = AttendanceModel::getInstance()->getRows($condition, $page, $pageSize);
        $this->json->toJson(
            array(
                "total"=>$row['total'],
                "rows"=>$row['list']
            )
        );
    }

    /**
     * 获取所有部门
     */
    public function DepartmentPatternAction()
    {
        $page     = P("page", 1);
        $pageSize = P("rows", 10);

        $row = OaModel::getInstance()->getDepartmentListAll($page, $pageSize);
        $this->json->toJson(
            array(
                "total"=>OaModel::getInstance()->getDepartmentListCount(),
                "rows"=>$row
            )
        );
    }




    public function AttendanceDelAction()
    {
        $id = trim(P("deleted"));
        if (AttendanceModel::getInstance()->del($id, false)) {
            $this->json->code('OK')->out();
        }
    }

    public function NotepadAction()
    {
        $this->view('oa/notepad.list', 'E');
    }

    public function NotepadPatternAction()
    {
        $page     = P("page", 1);
        $pageSize = P("rows", 10);
        $notelist = OaModel::getInstance()->getNotepadList($this->user['id'], $page, $pageSize);
        $this->json->toJson(
            array(
                "total"=>OaModel::getInstance()->getNotepadCount($this->user['id']),
                "rows"=>$notelist
            )
        );
    }

    public function NotepadAddAction()
    {
        $staff = StaffModel::getInstance()->getStaffInfo(array('sid'=>$this->user['id']));
        $nid    = P("id");
        $title  = P("title");
        $content = P("content");
        if (!$title || !$content || !$staff) {
            die(json_encode(array('err'=>-1, 'msg'=>'保存失败')));
        }
        $data = array(
            'staff_id'  => $staff['cid'],
            'title'     => $title,
            'content'   => $content,
        );
        $tmp = false;

        if (!$nid) {
            $data['created'] = date("Y-m-d H:i:s");
            OaModel::getInstance()->AddNotepad($data) && $tmp = true;
        } else {
            OaModel::getInstance()->EditNotepad($data, $nid) && $tmp = true;
        }

        if ($tmp) {
            die(json_encode(array('err'=>0, 'msg'=>'编辑成功')));
        } else {
            die(json_encode(array('err'=>-1, 'msg'=>'编辑失败')));
        }

    }

    public function NotepadEditAction()
    {
        $nid    = P("notepad_id");
        $title  = P("title");
        $content = P("content");

        if (!$title || !$content || !$nid) {
            die(json_encode(array('err'=>-1, 'msg'=>'编辑失败')));
        }

        $data = array(
            'title' => $title,
            'content' => $content,
            'created' => time()
        );
        if(OaModel::getInstance()->EditNotepad($data, $nid)) {
            die(json_encode(array('err'=>0, 'msg'=>'编辑成功')));
        } else {
            die(json_encode(array('err'=>-1, 'msg'=>'编辑失败')));
        }
    }

    public function NotepadViewAction()
    {
        $nid    = G("id");
        $this->data['notepad'] = OaModel::getInstance()->getNotepadInfo($nid);
        $this->view('oa/notepad.view', "E");
    }

    public function NotepadDelAction()
    {
        $id = trim(P("deleted"));
        if (OaModel::getInstance()->DelNotepad($id)) {
            die(json_encode(array('err'=>0, 'msg'=>'删除成功')));
        }
    }

    public function ProfileAction()
    {
        if (P("id")) {
            $data = array(
                'name' => P("name"),
                'sex'  => P("sex"),
                'age'  => P("age"),
                'birthday'     => P("birthday"),
                'mobile_phone' => P("mobile_phone"),
                'tel'          => P("tel"),
                'remark'      => P("remark")
            );
            if ($_FILES['avatar_url']['name']) {
                $result = UploadTool::doImages('avatar_url');
                $result['url'] && $data['avatar_url'] = $result['url'];
            }
            OaModel::getInstance()->staffEdit($data, P('id'));
            header("Location: /oa/profile/");
        }
        $staff = StaffModel::getInstance()->getStaffInfo(array('sid'=>$this->user['id']));
        $this->data['staff'] = $staff;
        $this->view("oa/profile", "E");
    }

    public function SetpasswordAction()
    {
        if (P("opass") && P("npass")) {
            if ($this->user['password'] != md5(P("opass"))) {
                die(json_encode(array('err'=>-1,'msg'=>'原始密码错误')));
            } else {
                $data = array('password'=>md5(P("npass")));
                if (OaModel::getInstance()->userEdit($data, $this->user['id'])) {
                    die(json_encode(array('err'=>0,'msg'=>'密码修改成功，退出后生效！')));
                }
            }
            exit;
        }
        $this->view("oa/setpassword", "E");
    }

    /**
     * 日程管理
     */
    public function ScheduleAction()
    {
        $this->view("oa/schedule.list", "E");
    }

    public function SchedulePatternAction()
    {
        $page     = P("page", 1);
        $pageSize = P("rows", 10);
        $schedule = OaModel::getInstance()->getScheduleList($this->user['id'], $page, $pageSize);
        $val = array();
        foreach ($schedule as $key=>$item) {
            $item['key'] = $key+1;
            $val[] = $item;
        }

        $this->json->toJson(
            array(
                "total"=>OaModel::getInstance()->getScheduleCount($this->user['id']),
                "rows"=>$val
            )
        );
    }

    public function ScheduleAddAction()
    {
        $staff = StaffModel::getInstance()->getStaffInfo(array('sid'=>$this->user['id']));
        $id = P("id", 0);
        $data = array(
            'staff_id' => $staff['cid'],
            'title'    => P('title'),
            'content'  => P('content'),
            'dates'    => P('dates'),
        );
        if ($id) {
            OaModel::getInstance()->EditSchedule($data, $id);
            die(json_encode(array('err'=>0,'msg'=>'编辑成功！')));
        } else {
            $data['created'] = date("Y-m-d H:i:s");
            OaModel::getInstance()->AddSchedule($data);
            die(json_encode(array('err'=>0,'msg'=>'新增成功！')));
        }
        die(json_encode(array('err'=>-1,'msg'=>'编辑失败！')));
    }

    public function ScheduleDelAction()
    {
        $id = trim(P("deleted"));
        if (OaModel::getInstance()->DelSchedule($id)) {
            die(json_encode(array('err'=>0, 'msg'=>'删除成功')));
        }
    }

    public function ScheduleViewAction()
    {
        $nid    = G("id");
        $this->data['schedule'] = OaModel::getInstance()->getScheduleInfo($nid);
        $this->view('oa/schedule.view', "E");
    }

    public function WeeklyReportsAction()
    {
        $s = G('s', 0);
        $this->data['suc'] = $s;
        $this->view('oa/weeklyReports.list', "E");
    }

    public function WeeklyReportsPatternAction()
    {
        $agency     = (int) P("agency");
        $staff      = (int) P("staff");
        $start_time = P("start_time");
        $end_time   = P("end_time");

        $page     = P("page", 1);
        $pageSize = P("rows", 10);

        $timewhere = '';
        $condition = '1=1';
//        if ($this->user["id"] > 1) {
//            $staffs = OaModel::getInstance()->getStaffInfo($this->user["id"]);
//            $timewhere .= ' and a.staff_id='.$staffs['staff_id'];
//        }

        if ($start_time) {
            $timewhere .= " and UNIX_TIMESTAMP(a.dates)>=".strtotime($start_time);
        }

        if ($end_time) {
            $timewhere .= " and UNIX_TIMESTAMP(a.dates)<=".strtotime($end_time);
        }

        if ($staff) {
            $condition .= " and a.staff_id=$staff ";
        } else {
            if ($agency) {
                $condition .= " and c.agency_id=$agency";
            }
        }
        $condition .= $timewhere;

        $schedule = OaModel::getInstance()->getWeeklyReportsList($condition, $page, $pageSize);
        $val = array();
        foreach ($schedule as $key=>$item) {
            $item['content'] = Isubstr($item, 100);
            $item['key'] = $key+1;
            $val[] = $item;
        }

        $this->json->toJson(
            array(
                "total"=>OaModel::getInstance()->getWeeklyReportsCount($condition),
                "rows"=>$val
            )
        );
    }

    public function WeeklyReportsAddAction()
    {
        $staff = StaffModel::getInstance()->getStaffInfo(array('sid'=>$this->user['id']));
        $id = P("id", 0);
        $data = array(
            'staff_id' => $staff['cid'],
            'title'    => P('title'),
            'content'  => P('content'),
            'dates'    => P('dates'),
        );

        /** 上传附件 **/
        if ($_FILES['attachment']['tmp_name']) {
            $result = UploadTool::doAttr('attachment');
            if ($result) {
                $data['attachment'] = $result['url'];
                $data['atta_name'] = $result['filename'];
            }
        }


        if ($id) {
            OaModel::getInstance()->EditWeeklyReports($data, $id);
            header("Location: /oa/weeklyReports/?s=1");exit;
            die(json_encode(array('err'=>0,'msg'=>'编辑成功！')));
        } else {
            $data['created'] = date("Y-m-d H:i:s");
            OaModel::getInstance()->AddWeeklyReports($data);
            header("Location: /oa/weeklyReports/?s=1");exit;
            die(json_encode(array('err'=>0,'msg'=>'新增成功！')));
        }
        die(json_encode(array('err'=>-1,'msg'=>'编辑失败！')));
    }

    public function WeeklyReportsDelAction()
    {
        $id = trim(P("deleted"));
        if (OaModel::getInstance()->DelWeeklyReports($id)) {
            die(json_encode(array('err'=>0, 'msg'=>'删除成功')));
        }
    }

    public function WeeklyReportsViewAction()
    {
        $nid    = G("id");
        $this->data['weeklyReports'] = OaModel::getInstance()->getWeeklyReportsInfo($nid);
        $this->view('oa/WeeklyReports.view', "E");
    }

    public function ReceivablesAction()
    {
        $this->view('oa/Receivables.list', "E");
    }

    public function ReceivablesPatternAction()
    {
        $condition = '1=1';
        $list = OaModel::getInstance()->getReceivablesList($condition);
        $this->json->toJson(
            array(
                "total"=>OaModel::getInstance()->getReceivablesCount($condition),
                "rows"=>$list
            )
        );
    }

    public function ReceivablesAddAction()
    {
        $staff = StaffModel::getInstance()->getStaffInfo(array('sid'=>$this->user['id']));
        $id = P("id", 0);
        $data = array(
            'staff_id'     => P('staff'),
            'customer_id'  => P('customer_id'),
            'title'        => P('title'),
            'must_time'    => P('must_time'),
            'reality_time' => P('reality_time'),
            'status'       => P('status')
        );



        if ($id) {
            OaModel::getInstance()->EditReceivables($data, $id);
            die(json_encode(array('err'=>0,'msg'=>'编辑成功！')));
        } else {
            $data['created'] = date("Y-m-d H:i:s");
            OaModel::getInstance()->AddReceivables($data);
            die(json_encode(array('err'=>0,'msg'=>'新增成功！')));
        }
        die(json_encode(array('err'=>-1,'msg'=>'编辑失败！')));
    }

    public function ReceivablesDelAction()
    {
        $id = trim(P("deleted"));
        if (OaModel::getInstance()->DelReceivables($id)) {
            die(json_encode(array('err'=>0, 'msg'=>'删除成功')));
        }
    }

    function CustomerdataAction()
    {
        $p["name"] = trim(P("key",""));
        $area = trim(P("area","1"));

        $areaList = CommonModel::getInstance()->getAreaList();
        $area_id = ArrayTool::ArrayToIDs($areaList,$area);
        $p["area"] = $area_id;

        $this->json->toJson(array("total"=>CommonModel::getInstance()->getCustomerCount($p),"rows"=>CommonModel::getInstance()->getCustomer($p)));
    }

    public function GetAreaAction()
    {
        $list = OaModel::getInstance()->getAreaList();
        $val = ArrayTool::ArrayToNode($list);
        $this->json->toJson(
            $val
        );
    }

    public function AftermarketAction()
    {
        $this->view('oa/Aftermarket.list', "E");
    }

    public function AftermarketPatternAction()
    {
        $status     = array(1=>'未收款',2=>'已收款');
        $condition = '1=1';
        $page       = P("page", 1);
        $pageSize   = P("rows", 10);
        $status2    = P("status2", 0);
        $customer_id    = P("customer_id", 0);
        $start_time    = P("start_time", 0);
        $end_time    = P("end_time", 0);
        if ($status2) {
            $condition .= " and a.status='".$status[$status2]."'";
        }

        if ($customer_id) {
            $condition .= " and a.customer_id=$customer_id";
        }

        if ($start_time) {
            $condition .= " and a.start_time>='".$start_time."'";
        }

        if ($end_time) {
            $condition .= " and a.end_time<='".$end_time."'";
        }
//echo $condition;exit;
        $list = OaModel::getInstance()->getAftermarketList($condition, $page, $pageSize);
        $this->json->toJson(
            array(
                "total"=>OaModel::getInstance()->getAftermarketCount($condition),
                "rows"=>$list
            )
        );
    }

    public function AftermarketAddAction()
    {
        $staff = StaffModel::getInstance()->getStaffInfo(array('sid'=>$this->user['id']));
        $id = P("id", 0);
        $data = array(
            'staff_id'     => P('staff'),
            'customer_id'  => P('customer_id'),
            'title'        => P('title'),
            'start_time'    => P('start_time'),
            'end_time'    => P('end_time'),
            'must_time'    => P('must_time'),
            'reality_time' => P('reality_time'),
            'status'       => P('status')
        );



        if ($id) {
            OaModel::getInstance()->EditAftermarket($data, $id);
            die(json_encode(array('err'=>0,'msg'=>'编辑成功！')));
        } else {
            $data['created'] = date("Y-m-d H:i:s");
            OaModel::getInstance()->AddAftermarket($data);
            die(json_encode(array('err'=>0,'msg'=>'新增成功！')));
        }
        die(json_encode(array('err'=>-1,'msg'=>'编辑失败！')));
    }

    public function AftermarketDelAction()
    {
        $id = trim(P("deleted"));
        if (OaModel::getInstance()->DelAftermarket($id)) {
            die(json_encode(array('err'=>0, 'msg'=>'删除成功')));
        }
    }
}
